/*************************************************
** 功能 : 设计某高校研究生 Graduate 类, 该类包含研究生姓名（string name)、性别 (bool gender)、学号 (int id)、
入学成绩（double score）、研究领域 (string research) 、指导教师 (string tutor) 
和学校名称（const string university）与该研究生类有关的函数如下：
初始化与释放研究生对象数据（三构一析）；采用普通成员函数形式输出研究生基本数据信息；采用常成员函数形式输出研究生的基本数据信息；
输出多个研究生对象的平均成绩 (要求在类内封装实现)；
以友元函数形式计算每个研究生对象的成绩等级（90 分以上输出 A, 80-89 分输出 B，70-79 分输出 C, 60-69 分输出 D，60 分以下输出 E)；
提示: string是C++系统内置的一个类, 可以直接使用,功能强大, 使用前带上头文件
** 作者 : Yang Lan
** 版本 : 2021-12-5 / 11:50
/**************************************************/

#include <iostream>
#include<string>
#include <cstdlib>
#include <windows.h>

using namespace std;

/*----------------------------------*
		Class Definition
*-----------------------------------*/
class Graduate
{
private:
	string name;
	bool gender;
	int id;
	double score;
	string research;
	string tutor;
	const string university;
	static double everageScore;
	static int population;
	static double TotalScore;
public:
	Graduate():university("NormalUniversity")
	{
		cout << "The constrructer was called !" << endl;
		gender = 1;
		id = 0;
	    score = 0;
		population++;
	}
	Graduate(string n, bool g, int i, double s, string r, string t) :university("NormalUniversity")
	{
		this->name = n;
		this->gender = g;
		this->id = i;
		this->score = s;
		this->research = r;
		this->tutor = t;
		population++;
		TotalScore += s;
	}
	Graduate(const Graduate& r) :university("NormalUniversity")
	{
		this->name = r.name;
		this->gender = r.gender;
		this->id = r.id;
		this->score =r.score;
		this->research = r.research;
		this->tutor = r.tutor;
		population++;
		TotalScore += r.score;
	}
	//输入学生信息
	void SetInformation()
	{
		cout << "name:";
		cin >> this->name;
		cout << "gender:";
		cin>>this->gender;
		cout << "id:";
		cin >> this->id;
		cout << "score:";
		cin >> this->score;
		cout << "research:";
		cin >> this->research;
		cout << "tutor:";
		cin >> this->tutor;
		TotalScore += this->score;
	}
	//普通函数部分
	static void GetEverage();
	void GetNorInform();
	void GetNorInform() const;
	friend void JudgeLevel(Graduate &A);

	~Graduate() //析构函数
	{
		cout << "The destructor was called !" << endl;
	}


};
//静态常量初始化
double Graduate::everageScore = 0;
int Graduate::population = 0;
double Graduate::TotalScore = 0;
//函数部分
void Graduate::GetEverage()
{
	everageScore = TotalScore / population;
	cout << "The everage score of all the students is:" << everageScore<<endl;
}
//普通函数输出学生基本信息、
void Graduate::GetNorInform()
{
	cout << endl << endl;
	cout << "Normal information:" << endl;
	cout << "name:" << name << endl;
	if (gender == 1)
		cout << "gender:" << "male" << endl;
	else
		cout << "gender:" << "female" << endl;
 	cout << "id:" <<id<< endl;
	cout << "score:" <<score<<endl;
	cout << "research:" <<research<<endl;
	cout << "tutor:" <<tutor<<endl;
	cout << "university:" <<university<<endl;
}

void Graduate::GetNorInform() const
{
	cout << endl << endl;
	cout << "Normal information:" << endl;
	cout << "name:" << name << endl;
	if (gender == 1)
		cout << "gender:" << "male" << endl;
	else
		cout << "gender:" << "female" << endl;
	cout << "id:" << id << endl;
	cout << "score:" << score << endl;
	cout << "research:" << research << endl;
	cout << "tutor:" << tutor << endl;
	cout << "university:" << university << endl;
}

void JudgeLevel(Graduate &A)
{
	if (A.score >= 90)
		cout << "The level of score is: A\n";
	else if (A.score >= 80)
		cout << "The level of score is: B\n";
	else if (A.score >= 70)
		cout << "The level of score is: C\n";
	else if (A.score >= 60)
		cout << "The level of score is: D\n";
	else
		cout << "The level of score is: E\n";
}

/*----------------------------------*
		Main Function
*-----------------------------------*/

int main()
{
	Graduate student[2];

	student[0].SetInformation();
	JudgeLevel(student[0]);
	
	student[1].SetInformation();
	JudgeLevel(student[1]);

	Graduate::GetEverage();

	student[0].GetNorInform();
	student[1].GetNorInform();

	system("pause");
	
	return 0;
}